package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.EaseUserMapper;
import com.ghck.server.model.EaseUser;
import com.ghck.server.model.query.EaseUserQuery;
import com.ghck.server.service.EaseUserService;

/**
 * 环信用户  <br>
 * t_ease_user <br>
 * v1.0 2016-05-06
 */
 @Service
 @Transactional
 public class EaseUserServiceImpl implements EaseUserService {
	
	private static final Logger logger = LoggerFactory.getLogger(EaseUserServiceImpl.class);
	
	@Autowired
	private EaseUserMapper easeUserMapper;
	
	/**
 	*根据ID删除 环信用户
 	*/
 	@Override
 	public Integer deleteEaseUserById(Integer id){
 		return easeUserMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 环信用户
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertEaseUser(List<? extends EaseUser> easeUsers){
		Integer count = easeUserMapper.batchInsert(easeUsers);
		return count;
 	}
 	/**
 	*新增 环信用户
 	*/
 	@Override
 	@Transactional
 	public Integer insertEaseUser(EaseUser domain){
		Integer id = easeUserMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 环信用户
 	*/
 	@Override
 	@Transactional
 	public Integer updateEaseUser(EaseUser domain){
		Integer count = easeUserMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 环信用户
 	*/
 	public EaseUser findEaseUserById(Integer id){
 		EaseUser result = easeUserMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 环信用户
 	*/
	public List<EaseUser> findEaseUserByQuery(EaseUserQuery query){
		query.dealWith();
		List<EaseUser> result = easeUserMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (EaseUser easeUser : result) {
				easeUser.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countEaseUserByQuery(EaseUserQuery query){
 		query.dealWith();
 		Integer result = easeUserMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<EaseUser> findEaseUserByIds(List<Integer> ids){
 		List<EaseUser> result = easeUserMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (EaseUser easeUser : result) {
				easeUser.dealWith();
			}
		}
		return result;
 	}
 	
}	